package com.bestcem.xm.award.grpc.service.param.requestaward;

import com.bestcem.xm.award.enums.SurveyStatusEnum;
import com.bestcem.xm.common.core.constant.RegTypes;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * 答卷信息参数
 *
 * @author jie.yao <jie.yao@idiaoyan.com>
 * @version v1.0
 * @date 2021/6/29 14:18
 */
@ToString
@NoArgsConstructor
@Getter
@Setter
public class RespondentParam {

    /**
     * 答卷id
     */
    @NotBlank(message = ErrorMessage.RESPONDENT_ID_NULL_ERROR)
    @Pattern(regexp = RegTypes.OBJECT_ID, message = ErrorMessage.RESPONDENT_ID_FORMAT_ERROR)
    private String id;

    /**
     * 答题端ip
     */
    private String ip;

    /**
     * 投放id
     */
    @NotBlank(message = ErrorMessage.DELIVER_ID_NULL_ERROR)
    @Pattern(regexp = RegTypes.OBJECT_ID, message = ErrorMessage.DELIVER_ID_FORMAT_ERROR)
    private String deliverId;

    /**
     * 答卷唯一标识
     */
    @Min(value = 1, message = ErrorMessage.RESPONDENT_SEQ_NULL_ERROR)
    private Integer seq;

    /**
     * 答卷状态 {@link SurveyStatusEnum}
     */
    @NotNull(message = ErrorMessage.RESPONDENT_STATUS_NULL_ERROR)
    @Range(max = 107L, message = ErrorMessage.RESPONDENT_STATUS_ERROR)
    private Integer status;

    /**
     * 答卷来源
     */
    private Integer source;

    /**
     * 发出请求的时间戳
     */
    private Long currentTime;

    /**
     * 答题花费时间
     */
    @Min(value = 1, message = ErrorMessage.COST_TIME_NULL_ERROR)
    private Integer costTime;

    public static class ErrorMessage {
        public static final String RESPONDENT_ID_NULL_ERROR = "答卷id不能为空";
        public static final String RESPONDENT_ID_FORMAT_ERROR = "答卷id格式错误";
        public static final String DELIVER_ID_NULL_ERROR = "投放id不能为空";
        public static final String DELIVER_ID_FORMAT_ERROR = "投放id格式错误";
        public static final String RESPONDENT_SEQ_NULL_ERROR = "答卷唯一表示不能为空";
        public static final String RESPONDENT_STATUS_NULL_ERROR = "答卷状态不能为空";
        public static final String RESPONDENT_STATUS_ERROR = "答卷状态异常";
        public static final String COST_TIME_NULL_ERROR = "答题时间不能为空";
    }
}
